package org.szx.model;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
import java.util.Set;


/**
 * The persistent class for the exam_user database table.
 * 
 */
@Entity
@Table(name="exam_user")
@NamedQuery(name="ExamUser.findAll", query="SELECT e FROM ExamUser e")
public class ExamUser implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="user_id")
	private String userId;

	private String address;

	@Temporal(TemporalType.DATE)
	private Date birthday;

	private String email;

	private int gender;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="last_lock_time")
	private Date lastLockTime;

	@Column(name="login_fail_count")
	private byte loginFailCount;

	private String password;

	private String tel;

	@Column(name="user_name")
	private String userName;

	//bi-directional many-to-many association to ExamRole
	@ManyToMany(mappedBy="examUsers", fetch=FetchType.EAGER,cascade=CascadeType.PERSIST)
	private Set<ExamRole> examRoles;

	//bi-directional many-to-many association to ExamSubject
	@ManyToMany(mappedBy="examUsers", fetch=FetchType.EAGER)
	private Set<ExamSubject> examSubjects;

	//bi-directional many-to-one association to ExamScore
	@OneToMany(mappedBy="examUser", fetch=FetchType.EAGER)
	private Set<ExamScore> examScores;

	public ExamUser() {
	}

	public String getUserId() {
		return this.userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Date getBirthday() {
		return this.birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public int getGender() {
		return this.gender;
	}

	public void setGender(int gender) {
		this.gender = gender;
	}

	public Date getLastLockTime() {
		return this.lastLockTime;
	}

	public void setLastLockTime(Date lastLockTime) {
		this.lastLockTime = lastLockTime;
	}

	public byte getLoginFailCount() {
		return this.loginFailCount;
	}

	public void setLoginFailCount(byte loginFailCount) {
		this.loginFailCount = loginFailCount;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getTel() {
		return this.tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getUserName() {
		return this.userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Set<ExamRole> getExamRoles() {
		return this.examRoles;
	}

	public void setExamRoles(Set<ExamRole> examRoles) {
		this.examRoles = examRoles;
	}

	public Set<ExamSubject> getExamSubjects() {
		return this.examSubjects;
	}

	public void setExamSubjects(Set<ExamSubject> examSubjects) {
		this.examSubjects = examSubjects;
	}

	public Set<ExamScore> getExamScores() {
		return this.examScores;
	}

	public void setExamScores(Set<ExamScore> examScores) {
		this.examScores = examScores;
	}

	public ExamScore addExamScore(ExamScore examScore) {
		getExamScores().add(examScore);
		examScore.setExamUser(this);

		return examScore;
	}

	public ExamScore removeExamScore(ExamScore examScore) {
		getExamScores().remove(examScore);
		examScore.setExamUser(null);

		return examScore;
	}

}